package br.com.teamware.ontrack.planning;

import com.domainlanguage.time.Duration;

public class PlanningCycleType {
	private String name;
	private Duration duration;
	private PlanningCycleType childCycle;
	
	public PlanningCycleType(String name, Duration duration) {
		this.name = name;
		this.duration = duration;
	}
	
	/**
	 * 
	 * @param name
	 * @param child What are the child cycle it holds
	 * @param quantity How many childs cycles have
	 */
	public PlanningCycleType(String name, PlanningCycleType child, int quantity) {
		this.childCycle = child;
		calculateDurationFromChilds(child, quantity);
	}

	private void calculateDurationFromChilds(PlanningCycleType child,
			int quantity) {
		for (int x = 0; x<quantity; x++) {
			duration = duration.plus(child.getDuration());
		}
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setDuration(Duration duration) {
		this.duration = duration;
	}

	public Duration getDuration() {
		return duration;
	}

	public void setChildCycle(PlanningCycleType childCycle) {
		this.childCycle = childCycle;
	}

	public PlanningCycleType getChildCycle() {
		return childCycle;
	}
}
